package luj.tool.jnproxyan.proxy.admin;

import luj.tool.jnproxyan.framework.proxy.actor.tell.ActorTeller;

import java.util.Map;
import java.util.function.BiFunction;

public interface AdminHttpHandler {

  interface Context {

    Param param(String name);

    String encodeJson(Map<String, ?> value);

    Ref actor(Class<?> type);

    void responsePage(Map<String, Object> model);
  }

  interface Param {

    String name();

    boolean exists();

    String asStr();

    int asInt();

    long asLong();

    double asDouble();
  }

  interface Ref {

    /**
     * @see #tell(Class, BiFunction)
     */
    @Deprecated
    void tell(Object msg);

    <M> void tell(Class<M> type, BiFunction<ActorTeller.MBean, M, ActorTeller.MBean> msg);
  }

  void onHandle(Context ctx) throws Exception;
}
